package com.demo.config;

import com.demo.utils.MongoDBChatMemoryStore;
import dev.langchain4j.memory.chat.ChatMemoryProvider;
import dev.langchain4j.memory.chat.MessageWindowChatMemory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 持久记忆配置（chatMemoryProvider）
 */
@Configuration
public class MemoryChatAssistant {
    @Autowired
    public MongoDBChatMemoryStore mongoDBChatMemoryStore;
    @Bean
    public ChatMemoryProvider chatMemoryProvider(){
        return memoryId-> MessageWindowChatMemory.builder()
                .id(memoryId)
                .maxMessages(10)
                .chatMemoryStore(mongoDBChatMemoryStore)
                .build();
    }
}
